<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.xmiles.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div class="page-header"
			style="margin-bottom: 0px; padding-bottom: 10px;"></div>

		<form id="queryForm">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">选择条件进行查询</h4>
								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>
							<div class="widget-body">
								<div class="widget-main">
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">手机号:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="mobnum"
												id="mobnum">
										</div>
									</div>
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">产品类型:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="prd_type">
												<option value="">全部</option>
												<option value="1">菠萝贷</option>
												<option value="2">微信菠萝贷</option>
												<option value="3">香蕉还卡</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
							<button class="btn btn-purple  no-border" type="button"
								name="btn-query" onclick="query_any()" id="btn-query">
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
								查询
							</button>
							&nbsp;&nbsp;&nbsp;
					        <button class="btn btn-grey  no-border" type="reset">
						     <i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
						              重置
					         </button>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>

	<%@ include file="/common/common-js.jsp"%>
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script type="text/javascript" src="${ctx}/ace/js/jquery.dataTables.min.js"></script>
	
	<script type="text/javascript">
	
		function loadlist() {
			var form = document.forms["queryForm"];
			form.action = ctx + "/userpoint/exportData.action";
			form.submit();
		}
		
		var souceList = null;
		//【查询】按钮Click事件
		function query_any() {
			$(".load_bg").removeAttr("style");
			$(".load_img").removeAttr("style");
			if (jqTable != null) {
				jqTable.fnDraw();
			} else {
				loaddata();
			}
		}
		var jqTable = null;
		var loaddata = function() {
			jQuery(function($) {
				jqTable = $('#jquery-table').dataTable(
					{
						//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
						"columnDefs" : [
						{
							"title" : "手机号码",
							"name" : "mobnum",
							"data" : "mobnum",
							"targets" : [ 0 ],
							"bSortable" : false,
						},
						{
							"title" : "产品类型",
							"name" : "prd_type",
							"data" : "prd_type",
							"targets" : [ 1 ],
							"render": function(value, type, row) { // 返回自定义内容
								if(value == 1) {
									return "菠萝贷";
								} else if (value == 2){
									return "微信菠萝贷";
								} else if (value == 3){
									return "香蕉还卡";
								} else {
									return "--";
								}
			                }
						}, 
						{
							"title" : "积分余额",
							"name" : "avalue",
							"data" : "avalue",
							"targets" : [ 2 ],
							"render": function(value, type, row) { // 返回自定义内容
								return (row.avalue - row.bvalue);
			                }
						}, 
						{		
			    		    "title":"操作",
			    		    "name":"userid",
			    		    "data": "userid",
			    	  	    "targets": [3], 
			    	  	    "bSortable": false,
	 		    	  	    "width": "8%",
	 		    	  	    "render": function(value, type, row) { // 返回自定义内容
	 		    	  	    	return "<button type='button' value='"+value+"' class='btn btn-primary btn-sm no-border infoID'>积分管理</button>";
		                    }
			    	    },],
						"sAjaxSource" : ctx + "/userpoint/queryuserpoint.action",
						"fnServerData" : function(sSource, aoData,
								fnCallback) {//从服务器请求数据
							var data = $('#queryForm').serializeObject();
							data.aoData = JSON.stringify(aoData);
							$.ajax({
								"dataType" : 'json',
								"type" : "POST",
								"url" : sSource,
								"data" : data,
								"success" : function(resp) {
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
									$("#hidden_pass").attr("style",
											"display:block");
									$('#jquery-table').removeClass(
											"dataTable");
									fnCallback(resp);
									initListPage();
								},
								"error" : function(XMLHttpRequest,
										textStatus, errorThrown) {
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
									alert('请求服务器错误,请刷新重试！！'); //错误提示，包括服务器重启导致的session失效
								}
							});
						},
						"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
			  				//=====================这里实现行双击事件======================//
			  				$(nRow).on('click', 'td .infoID', function (index) {
			  					var id = $(this).val();
								var url = "/userpoint/input.jsp?userid=" + id;
								url = encodeURI(url);
								openDialogWithRand(url,800,465,"",function(data){
									query_any();
								});
						    });
			  			},
						"bDestroy" : true,
						"bScrollInfinite" : true,
						"sScrollXInner" : "100%",
						"sScrollY" : "100%",//如果不设置，IE会有问题
						"aaSorting" : [ [ 0, "desc" ] ]
					//初始化加载，默认按第几列排序、排序方式（列从0开始计算）
					});
			});
		}
		
		$(document).ready(function() {
			query_any();
		});
	</script>
</body>
</html>